# Contributor: Roberto Oliveira <robertoguimaraes8@gmail.com>
# Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
pkgname=gradle
pkgver=8.7
pkgrel=1
pkgdesc="Build tool with a focus on build automation and support for multi-language development"
url="https://gradle.org/"
arch="noarch"
options="!check"
license="Apache-2.0"
source="https://services.gradle.org/distributions/gradle-$pkgver-bin.zip"

# highest supported version in community
case "$CARCH" in
arm* | x86)
	depends="openjdk8"
	;;
*)
	depends="openjdk21"
	;;
esac

# secfixes:
#   7.6.1-r0:
#     - CVE-2023-26053
#   7.2-r0:
#     - CVE-2021-32751
#   6.8.3-r0:
#     - CVE-2020-11979

package() {
	local gradlehome="/usr/share/java/$pkgname"
	local destdir="$pkgdir/$gradlehome"

	install -dm755 "$destdir"/bin
	rm bin/*.bat
	install -m755 bin/* "$destdir"/bin

	install -dm755 "$pkgdir"/usr/bin
	ln -sf $gradlehome/bin/gradle "$pkgdir"/usr/bin/gradle

	install -dm755 "$destdir"/lib
	cp -a lib "$destdir"/

	# NOTICE file should be redistributed for derivative works
	local file; for file in LICENSE NOTICE; do
		install -m644 -D $file "$pkgdir"/usr/share/licenses/$pkgname/$file
	done
}

sha512sums="
ddbd320de140634087904c0d0047b146b9697eb0d054a7eada24d6179b65dbeb2189e1c9def463e4788fa1a7f02a720ab9b7bdcdd9bb529770985283d0e51e1a  gradle-8.7-bin.zip
"
